#ifndef _OC_DynLib_H__
#define _OC_DynLib_H__

#include "Prerequisites.h"

#if _WIN32
struct HINSTANCE__;
#endif

namespace OCPP {
    /** \addtogroup Core
    *  @{
    */
    /** \addtogroup General
    *  @{
    */

#if _WIN32
    typedef struct HINSTANCE__* DYNLIB_HANDLE;
#else
    typedef void* DYNLIB_HANDLE;
#endif

    /** Resource holding data about a dynamic library.
        @remarks
            This class holds the data required to get symbols from
            libraries loaded at run-time (i.e. from DLL's for so's)
        @author
            Adrian Cearn„u (cearny@cearny.ro)
        @since
            27 January 2002
    */
    class _MainExport DynLib
    {
    private:
        String mName;
        /// Gets the last loading error
        String dynlibError(void);
    public:
        /** Default constructor - used by DynLibManager.
            @warning
                Do not call directly
        */
        DynLib( const String& name );

        /** Default destructor.
        */
        ~DynLib();

        /** Load the library
        */
        void load();
        /** Unload the library
        */
        void unload();
        /// Get the name of the library
        const String& getName(void) const { return mName; }

        /**
            Returns the address of the given symbol from the loaded library.
            @param
                strName The name of the symbol to search for
            @return
                If the function succeeds, the returned value is a handle to
                the symbol.
            @par
                If the function fails, the returned value is <b>NULL</b>.

        */
        void* getSymbol( const String& strName ) const throw();

    private:

        /// Handle to the loaded library.
        DYNLIB_HANDLE mInst;
    };
    /** @} */
    /** @} */

}

#endif
